package com.songshuai.pangu.api.component;

import com.alibaba.fastjson.JSONObject;
import com.songshuai.pangu.api.controller.BaseController;
import com.songshuai.webapi.baseapi.dto.pangu.request.salesclient.CustomerListReqDto;
import com.songshuai.webapi.baseapi.pojo.BaseParmDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 对接盘古-我的客户列表
 */
@Slf4j
@Component
public class SalesClientComponent extends BaseController {


    //我的客户列表
    @Value("${pangu.sales.getSaleCustomerList}")
    private String queryGetSaleCustomerListUrl;



    /**
     * 查看我的客户列表
     * @param searchStr 搜索字符串
     * @param userId 销售ID
     * @return
     */
    public String queryGetSaleCustomerList(BaseParmDto<CustomerListReqDto> request){
        try {
            JSONObject object = new JSONObject();
            JSONObject object2 = new JSONObject();

            object.put("param",request.getParam().getSearchStr());
            object.put("intentionGrade","0");
            object.put("saleId",request.getParam().getCurrentUserId());
            object.put("meetingNo","");
            object2.put("Where",object);
            object2.put("PageIndex",request.getPageIndex());
            object2.put("PageSize",request.getPageSize());
            object2.put("OrderBy","");
            object2.put("SortCol","0");
            log.info("queryGetSaleCustomerList:jsonParam{}",object2.toJSONString());
            return callPanguApi(object2,queryGetSaleCustomerListUrl);

        } catch (Exception e) {
            log.error("请求盘古-查看我的客户列表异常",e);
        }
        return null;
    }

}
